package com.wtp.wallpaper.task;

import com.wtp.wallpaper.annotation.ScheduledAnnotation;
import com.wtp.wallpaper.bloomfilter.BloomFilterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@ScheduledAnnotation(value = "重制布隆过滤器",
        cron = "0 0 0/6 * * ?",
        description = "定时重制布隆过滤器，减少冲突，六小时执行一次")
public class RebuildBloomFilterTask implements Runnable{

    @Autowired
    private BloomFilterService bloomFilterService;
    //@Scheduled(fixedRate = 3600000)
    public void rebuildBloomFilter() {
        log.info("开始重建布隆过滤器");
        bloomFilterService.rebuildBloomFilter();
        log.info("重建布隆过滤器完成");
    }

    @Override
    public void run() {
        rebuildBloomFilter();
    }
}
